package com.itheima;

import com.itheima.config.SpringConfig;
import com.itheima.dao.BookDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 配置单例还是非单例？
 *      在类上加上@Scope注解，@Scope("prototype)
 * 配置生命周期方法也是加注解:
 * @PostConstructor -->在构造方法之前
 * @PreDestory  -->在销毁方法之后
 *
 * 高版本的jdk没有这两个注解，要先导入 jakarta.annotation-api 包
 */
public class App {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext cx =new AnnotationConfigApplicationContext(SpringConfig.class);

        BookDao bookDao1 = cx.getBean("bookDao" , BookDao.class);
        BookDao bookDao2 = cx.getBean(BookDao.class);

        System.out.println(bookDao1);
        System.out.println(bookDao2);

        cx.close();
    }
}
